package com.sj.uerService;

import com.sj.Dao.userDao;
import com.sj.JdbcUtil.MD5;
import com.sj.user.User;

public class userService {
    userDao userDao = new userDao();
    public String login(String username,String password){

        User u = userDao.loginon(username);
        if(u==null){
            return "用户不存在";
        }
        String md5Password = MD5.md5(password);
        if(!md5Password.equals(u.getPassword())){
            return "密码不正确";
        }
            return "登陆成功";


    }

    public String insertinto(String username,String password,String password1){
//        1.判断用户是否存在
        User log = userDao.loginon(username);
        if(log!=null){
            return "用户存在";
        }
        if(!password.equals(password1)){
            return "密码不一致";
        }
        String s = MD5.md5(password);
        int insertuer = new userDao().insertuer(new User(username, s));
        if(insertuer==0){
            return "注册失败";
        }
        return "注册成功";

    }
}
